package com.rd.student.wulian.wanggaobo.day0807;

import java.io.File;

public class IOTest {
    public static void main(String[] args) {
        String Path = "D:\\JavaCode\\Code\\corejava\\Test";

        deleteDir(Path);
    }

    public static void deleteDir(String dirPath) {
        File dir = new File(dirPath);

        if (!dir.exists()) {
            return;
        }
        File[] files = dir.listFiles();
        if (files != null) {
            for (File file : files) {
                if (file.isDirectory()) {
                    deleteDir(file.getAbsolutePath());
                } else {
                    file.delete();
                }
            }
        }
        dir.delete();
    }
}